package com.wryyyyy.controller;

import com.wryyyyy.dto.Result;
import com.wryyyyy.dto.UserDTO;
import com.wryyyyy.service.IHistService;
import com.wryyyyy.utils.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wryyyyy
 * @since 2023-11-12
 */
@Slf4j
@RestController
@RequestMapping("/hist")
public class HistController {
    @Resource
    private IHistService histService;

    /**
     * 根据 浏览历史查询
     * @return 菜品列表
     */
    @GetMapping("/list")
    public Result query(
            @RequestParam(value = "current", defaultValue = "1") Integer current,
            @RequestParam(value = "size", defaultValue = "10") Integer size
    ) {
        UserDTO user = UserHolder.getUser();
        return histService.queryAll(user.getId(), current, size);
    }
}

